<?php declare(strict_types=1);

namespace app\controller;
use app\exception\Failure;
use app\exception\RequestMethodInvalidate;
use app\exception\Success;
use app\facade\logic\Auth as FaAuthLogic;

class Auth extends AuthBase{

    /**
     * lst
     * @Route("/auth/rights")
     */
    // Get Auth List
    public function rights(){
        // REQUIRE POST METHOD
        if($this->request->isPost()){
            // Get User Rights
           $result =  FaAuthLogic::getUserRightsOfGroups();
           throw new Success($result);
        }
        throw new RequestMethodInvalidate();
    }

    /**
     * saveAuth
     * @Route("/auth/saveAuth")
     */
    public function saveAuth(){
        if($this->request->isPost()){
            // Get User Rights
            $result =  FaAuthLogic::saveAuth();
            if($result){
                throw new Success();
            }else{
                throw new Failure();
            }
        }
        throw new RequestMethodInvalidate();
    }
}
